package cn.kgc.tcst004.maoqichao.crowdfundingadminspringboot.controller;

import cn.kgc.tcst004.maoqichao.crowdfundingadminspringboot.common.ResultEntity;
import cn.kgc.tcst004.maoqichao.crowdfundingadminspringboot.pojo.Cert;
import cn.kgc.tcst004.maoqichao.crowdfundingadminspringboot.pojo.Message;
import cn.kgc.tcst004.maoqichao.crowdfundingadminspringboot.service.MessageService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/message")
public class MessageController {
    @Resource
    MessageService messageService;
    @RequestMapping("/to/message")
    public String message(){
        return "message-page";
    }

    //查询
    @ResponseBody
    @RequestMapping("/select/message")
    public ResultEntity<List<Message>> selectAllMessage(){
        List<Message> messages = messageService.selectAllMessage();
        return ResultEntity.successWithoutData(messages);
    }
    //修改
    @ResponseBody
    @RequestMapping("/update/message")
    public ResultEntity<String> updateMessage(Message message) {
        messageService.updateMessage(message);
        return ResultEntity.successWithoutData();
    }
}
